# 데이터 읽기
<- reactive({
dbData $depend()
dbTriggeras.data.table(dbGetQuery(con, 'SELECT id, dates, cat_big, type, cat_small,
weight, no_rep, no_set,
weight * no_rep * no_set as volume, memo
FROM diary'))
})
# 데이터 db에 입력
observeEvent(input$write,{
<- list(
record dates = input$dates,
cat_big = input$cat_big,
type = input$type,
cat_small = input$cat_small,
weight = input$weight,
no_rep = input$no_rep,
no_set = input$no_set,
memo = input$memo
)if(input$cat_small=="" |
$no_rep==0 |
input$no_set==0){
input::show_alert(
shinyWidgetstype = 'error',
title='Oops!!',
text = "운동 일지 빈칸이 존재함.")
}else {
<- sqlInterpolate(con,
query 'INSERT INTO diary ([dates],[cat_big],[type],[cat_small],[weight],[no_set],[no_rep],[memo])
VALUES (?dates, ?cat_big, ?type, ?cat_small, ?weight, ?no_set, ?no_rep, ?memo);',
dates = input$dates,
cat_big = input$cat_big,
type = input$type,
cat_small = input$cat_small,
weight = input$weight,
no_rep = input$no_rep,
no_set = input$no_set,
memo = input$memo
)dbExecute(con, query)
$trigger()
dbTrigger::show_alert(
shinyWidgetstype='success',
title='Success !!',
text = "운동일지 저장 완료.")
Sys.sleep(2)
# session$reload()
} })
observeEvent(input$records_cell_edit, {
<- input$records_cell_edit$row; print(row)
row <- input$records_cell_edit$col; print(column)
column <- input$records_cell_edit$value; print(value)
value <- dt()[row, id] # 변경id
target_id
<- names(dt())[column+1]
edited_col_name dt()[row, col := input$records_cell_edit$value,
= list(col = edited_col_name)]
env
<- dbSendQuery(con,
query paste0("UPDATE diary SET '",edited_col_name,"' = ? where id = ?"),
params=c(value, target_id)
)::dbClearResult(query)
DBI$trigger()
dbTrigger
})
<- dbSendQuery(con,
query paste0("UPDATE diary SET '",edited_col_name,"' = ? where id = ?"),
params=c(value, target_id)
)::dbClearResult(query)
DBI$trigger()
dbTrigger})